import requests
from config import conf


dir = conf.get_case_path()
print(dir)

def push_test_info():
    wehook = 'https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token=w8Y8z6JXAp8018DgNoMQ2MWSQHBpT4AtX05rlX2ZAsmj9onOaOApBwg6ixTjb85gsdZ-KDx3r8E52F8E-AN1zNSgEgKf8pUHwM3dvHkNCjPPWiN5iMTNYHDN8bWARp3U7v9IsaiLv_ycWCddeSEnBPq3UuxLIKV2FXkOskJrCZvj2Upl1oJiPg3Ns6YxhBgGKAnspxc5Oq0z_tfR1ZcAmw'
    headers = {"Content-Type": "application/json"}
    data = {
        "chatid": "654321",
        "msgtype": "text",
        "text": {
            "content": "你的快递已到\n请携带工卡前往邮件中心领取"
        },
        "safe": 0
    }

    s = requests.post(url=wehook, headers=headers, json=data)
    print(s.json())


def get_accesstoken():
    url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wwc04355d6ef5d1561&corpsecret=5MSelEYBCXZjlAqormz1Si6RCgYIt9ut7dvmL3-_lwU'
    headers = {"Content-Type": "application/json"}
    s = requests.post(url=url, headers=headers)
    print(s.json())


def get_deptid():
    url = 'https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=szlJLV3Log6e6UHbvhWEKU5gMzrofFb8iQjxlesG2I09VYhJcE8s_09MduTiPQbqEQEGL6LyEb__c2jqSUJ7f1wonDDBnf0cIaO7qVC3jg3C9oy2SzHR5ck0TVcjDx59kQZ0CW1LaoGcE71Pj5mDWxiYqZR6pXn8ENe5omEoSjHqwzY5JiUf2FlSvewgg6ggjnKwxeB6sSsgNY_Iuv4DGQ&department_id=1'
    headers = {"Content-Type": "application/json"}
    s = requests.get(url=url, headers=headers)
    print(s.json())


# if __name__ == '__main__':
    # get_deptid()
    # push_test_info()
    # get_accesstoken()

# import unittest from unittestreport import TestRunner
# # 收集用例到套件
# suite = unittest.defaultTestLoader.discover(CASE_DIR)
# runner = TestRunner(suite)
# # 执行用例
# runner.run()
# url = "https://oapi.dingtalk.com/robot/send?access_token=6e2a63c2b9d870ee878335b5ce6d5d10bb1218b8e64a4e2b55f96a6d116aaf50"
# # 发送钉钉通知
# runner.dingtalk_notice(url=url, key='钉钉安全设置的关键字',secret='钉钉安全设置签名的秘钥')
# # 备注：关键字和秘钥，根据创建钉钉机器人时设置的去添加，没有设置就不需要传这个参数。
